﻿@using Gx.Model.ViewModel;
@model LKWarehouseEntryDto
@{
    ViewBag.Title = "编辑零仓入库单";
    Layout = "~/Views/Shared/InfoMaste.cshtml";
}
<script src="~/Js/Global.js?v=20240706"></script>
<script type="text/javascript">
    $(function () {
        InitCustomer();
        InitChargingUnitCombobox();
        InitColdAlgorithmCombobox();
        $('#CustomerId').combogrid('setValue', '@Model.WarehouseEntry.CustomerId');
        $('#ContractNo').combogrid('setValue', '@Model.WarehouseEntry.ContractNo');
        $('#sbIsByTon').switchbutton({ checked: @Html.Raw(Model.WarehouseEntry.IsByTon ? "true" : "false") });
        //initContract();
    });

    var costdom = new Array();
    var detaildom = new Array();

    function initDom() {
        costdom.length = 0;
        detaildom.length = 0;
        $("input[type='hidden'][id^='CostDomId']").each(function () {
            var d = $(this).val();
            if ($.inArray(d, costdom) === -1) {
                costdom.push(d);
            }
        });
        $("input[type='hidden'][id^='DetailDomId']").each(function () {
            var d = $(this).val();
            if ($.inArray(d, detaildom) === -1) {
                detaildom.push(d);
            }
        });

    }

    function initContract() {
        /*$("#hidCustomerId").val(row.Id);*/
        $('#ContractNo').combogrid({
            url: "/LKWarehouseContract/GetZeroContractByCustomerId",
            method: 'post',
            mode: 'remote',
            panelWidth: 500,
            idField: 'ContractNo',
            textField: 'ContractNo',
            onSelect: function () {
                var g = $('#ContractNo').combogrid('grid');
                var row = g.datagrid('getSelected');
                loadContractInfo(row);
            },
            columns: [[
                { field: 'ContractType', title: 'ContractType', hidden: true },
                { field: 'ContractNo', title: '合同', width: 120, align: 'right' },
                { field: 'ContractTypeName', title: '合同类型', width: 150, align: 'right' },
                { field: 'ChargingUnit', title: 'ChargingUnit', hidden: true },
                { field: 'ChargingUnitName', title: 'ChargingUnitName', hidden: true },
                { field: 'ColdAlgorithm', title: 'ColdAlgorithm', hidden: true },
                { field: 'ColdAlgorithmName', title: 'ColdAlgorithmName', hidden: true },
                { field: 'Cycle', title: 'Cycle', hidden: true },
                { field: 'ColdUnitPrice', title: 'ColdUnitPrice', hidden: true },
            ]],
            onLoadSuccess: function (data) {
                //var dataCount = data.total; // 获取加载成功后的数据条数
                if (data.total == 1) {
                    var row = data.rows[0];
                    loadContractInfo(row);
                }
            }
        });

    }

    function loadContractInfo(row) {
        $('#ContractNo').combogrid('setValue', row.ContractNo);
        $('#ContractId').val(row.ContractId);
        $('#RentalWarehouseTypeName').textbox('setValue', row.ContractTypeName);
        $('#RentalWarehouseType').val(row.ContractType);
        $('#ChargingUnitName').textbox('enable');
        $('#ColdAlgorithmName').textbox('enable');
        $('#Cycle').numberbox('enable');
        $('#ColdUnitPrice').numberbox('enable');

        $('#ChargingUnitName').textbox('setValue', row.ChargingUnitName);
        $('#ChargingUnit').val(row.ChargingUnit);

        $('#ColdAlgorithmName').textbox('setValue', row.ColdAlgorithmName);
        $('#ColdAlgorithm').val(row.ColdAlgorithm);

        $('#Cycle').numberbox('setValue', row.Cycle);
        $('#ColdUnitPrice').numberbox('setValue', row.ColdUnitPrice);

        if (row.ContractType != 1) {
            $('#ChargingUnitName').textbox('disable');
            $('#ColdAlgorithmName').textbox('disable');
            $('#Cycle').numberbox('disable');
            $('#ColdUnitPrice').numberbox('disable');
        }
    }

    function addDom() {
        var domId = $("#DomNum").val();
        $.post("/GoodsOrder/_AddLKWarehouseEntryDetail", { domId: domId }, function (html) {
            $.messager.progress('close');
            $("#detailgird").append(html);
            $.parser.parse($("#" + domId));
            InitWareHouse(domId);
            InitGoods(domId);
            InitGoodsSpecCombobox(domId);
            $("#DomNum").val(Number(domId) + 1);

            initDom();
            var d = Number(domId);
            if ($.inArray(d, detaildom) === -1) {
                // 如果不存在，则添加到数组中
                detaildom.push(d);
            }
        });
    }
    function delDom(id) {
        $("#" + id).remove();
        //domId = Number(domId) - 1;
        removecalculateWeight();
    }

    function addDom2() {
        var domId2 = $("#CostDomNum").val();
        $.post("/GoodsOrder/_AddLKWarehouseEntryCost", { domId: domId2 }, function (html) {
            $.messager.progress('close');
            $("#costgird").append(html);
            $.parser.parse($("#CostTr" + domId2));
            InitCostTypesCombogrid2(domId2, initCostType);
            InitChargingUnitCombobox(domId2);
            $("#CostDomNum").val(Number(domId2) + 1);

            initDom();
            var d = Number(domId2);
            if ($.inArray(d, costdom) === -1) {
                // 如果不存在，则添加到数组中
                costdom.push(d);
            }
        });
    }

    function print() {
        var printUrl = "/GoodsOrder/LKZeroWarehouseEntryPrint?id=" + @Model.WarehouseEntry.Id;
        window.open(printUrl, "_blank");
    }

    function delDom2(id) {
        $("#CostTr" + id).remove();

        //domId2 = Number(domId2) - 1;
        removecalculateAmount();
    }

    function initCostType(row) {
        var id = row.did;
        $("#CostTypeId" + id).val(row.data.Id);//combobox('setValue', rowData.Id);
        $("#CostType" + id).combobox('setValue', row.data.CostTypeName);
        $("#ChargingUnit" + id).combobox('setValue', row.data.Unit);
        $("#UnitPrice" + id).numberbox('setValue', row.data.UnitPrice);
    }

    function querycustomer2() {
        $("#CustomerId").combogrid("grid").datagrid("reload", { "Customer": $("#SelectCustomerText2").val() });
    }

    //计算总重量
    function calculateWeight() {
        initDom();
        var triggerControl = this;
        var value = $(triggerControl).numberbox('getValue');

        //获取triggerControl的id的最后一个字符
        var id = $(triggerControl).attr("id");
        var lastChar = id.substr(id.length - 1, 1);
        var number = $("#Number" + lastChar).numberbox('getValue') * 1;
        var weight = $("#Weight" + lastChar).numberbox('getValue') * 1;
        var tonweight = (number * weight.toFixed(4)) / 1000;
        $("#TonWeight" + lastChar).numberbox('setValue', tonweight);

        var totalton = 0;
        var total = 0;
        detaildom.forEach(function (value, index) {
            var i = value;
            var numbers = $("#Number" + i).numberbox('getValue') * 1;
            var weights = $("#Weight" + i).numberbox('getValue') * 1;

            var tonweight = (numbers * weights.toFixed(4)) / 1000;
            totalton += tonweight;
            total += numbers;
        });
        $("#TotalTon").numberbox('setValue', totalton);
        $("#Total").numberbox('setValue', total);
    }

    function removecalculateWeight() {
        initDom();
        var totalton = 0;
        var total = 0;
        detaildom.forEach(function (value, index) {
            var i = value;
            var numbers = $("#Number" + i).numberbox('getValue') * 1;
            var weights = $("#Weight" + i).numberbox('getValue') * 1;

            var tonweight = (numbers * weights.toFixed(4)) / 1000;
            totalton += tonweight;
            total += numbers;
        });
        $("#TotalTon").numberbox('setValue', totalton);
        $("#Total").numberbox('setValue', total);
    }

    function calculateAmount() {
        initDom();
        var triggerControl = this;
        var value = $(triggerControl).numberbox('getValue');

        //获取triggerControl的id的最后一个字符
        var id = $(triggerControl).attr("id");
        var lastChar = id.substr(id.length - 1, 1);
        var number = $("#CNumber" + lastChar).numberbox('getValue') * 1;
        var unitprice = $("#UnitPrice" + lastChar).numberbox('getValue') * 1;
        var amount = (number * unitprice).toFixed(2);
        $("#Amount" + lastChar).numberbox('setValue', amount);

        var totalAmount = 0.00;
        costdom.forEach(function (value, index) {
            var i = value;
            var numbers = $("#CNumber" + i).numberbox('getValue') * 1;
            var unitprices = $("#UnitPrice" + i).numberbox('getValue') * 1;

            var tonam = (numbers * unitprices).toFixed(2) * 1;
            totalAmount += tonam;
        });
        $("#Amount").numberbox('setValue', totalAmount);
    }

    function removecalculateAmount() {
        initDom();
        var totalAmount = 0.00;
        costdom.forEach(function (value, index) {
            var i = value;
            var numbers = $("#CNumber" + i).numberbox('getValue') * 1;
            var unitprices = $("#UnitPrice" + i).numberbox('getValue') * 1;

            var tonam = (numbers * unitprices).toFixed(2) * 1;
            totalAmount += tonam;
        });
        $("#Amount").numberbox('setValue', totalAmount);
    }


    function editLKWarehouseEntry(isconfirm) {
        var validate = $("#fm").form("validate")
        if (!validate) {
            return;
        }
        var status = 0;
        if (isconfirm) {
            status = 1;
        }
        var data = {
            "Id": $("#Id").val(),
            "BillNo": $("#BillNo").textbox('getValue'),
            "EntryTime": $("#EntryTime").datebox('getValue'),
            "CarNumber": $("#CarNumber").textbox('getValue'),
            "PorterNo": $("#PorterNo").textbox('getValue'),
            "CustomerId": $("#CustomerId").combogrid('getValue'),//$("#hidCustomerId").val(),
            "CustomerNo": $("#CustomerId").combogrid('getText'),
            "CustomerName": $("#CustomerName").textbox('getValue'),
            "ContractNo": $("#ContractNo").textbox('getValue'),
            "RentalWarehouseType": $("#RentalWarehouseType").val(),//.combobox('getValue'),
            "ChargingUnit": $("#ChargingUnit").val(),//.combobox('getValue'),
            "ColdAlgorithm": $("#ColdAlgorithm").val(),//.combobox('getValue'),
            "Cycle": $("#Cycle").numberbox('getValue'),
            "ColdUnitPrice": $("#ColdUnitPrice").numberbox('getValue'),
            "TotalTon": $("#TotalTon").numberbox('getValue'),
            "Total": $("#Total").numberbox('getValue'),
            "Amount": $("#Amount").numberbox('getValue'),
            "Tonnage": $("#Tonnage").numberbox('getValue'),
            "IsByTon": $('#sbIsByTon').switchbutton('options').checked,
            "ContainerNumber": $("#ContainerNumber").textbox('getValue'),
            "Remark": $("#Remark").val(),
            "BeginTime": $("#BeginTime").datebox('getValue'),
            "EndTime": $("#EndTime").datebox('getValue'),
            "Status": status
        };


        initDom();
        var detailList = new Array();
        detaildom.forEach(function (value, index) {
            var i = value;
            var Id = $("#DetailId" + i).val();
            var EntryId = $("#EntryId" + i).val();
            var GoodsNo = $("#GoodsNo" + i).textbox('getValue');
            var GoodsId = $("#GoodsId" + i).combobox('getValue');
            var GoodsSpecId = $("#GoodsSpecId" + i).combobox('getValue');
            var WareHouseId = $("#WareHouseId" + i).combobox('getValue');

            var GoodsName = $("#GoodsId" + i).combobox('getText');
            var GoodsSpecName = $("#GoodsSpecId" + i).combobox('getText');
            var WareHouseName = $("#WareHouseId" + i).combobox('getText');

            var Weight = $("#Weight" + i).numberbox('getValue');
            var number = $("#Number" + i).numberbox('getValue');
            var Area = $("#Area" + i).numberbox('getValue');
            var AvNumber = $("#AvNumber" + i).numberbox('getValue');
            var TonWeight = $("#TonWeight" + i).numberbox('getValue');
            var PlateNumber = $("#PlateNumber" + i).numberbox('getValue');
            var ProductionDate = $("#ProductionDate" + i).datebox('getValue');
            var ExpirationDate = $("#ExpirationDate" + i).datebox('getValue');
            var ProducingArea = $("#ProducingArea" + i).textbox('getValue');
            var Remark = $("#Remark" + i).textbox('getValue');
            //var Remark1 = $("#Remark1" + i).textbox('getValue');
            //var Remark2 = $("#Remark2" + i).textbox('getValue');
            //var Remark3 = $("#Remark3" + i).textbox('getValue');
            var Processed = $("#sbProcessed" + i).switchbutton('options').checked;

            var detail = {
                "Id": Id,
                "EntryId": EntryId,
                "GoodsNo": GoodsNo,
                "GoodsId": GoodsId,
                "GoodsSpecId": GoodsSpecId,
                "WareHouseId": WareHouseId,
                "GoodsName": GoodsName,
                "GoodsSpecName": GoodsSpecName,
                "WareHouseName": WareHouseName,
                "Weight": Weight,
                "Number": number,
                "Area": Area,
                "AvNumber": AvNumber,
                "TonWeight": TonWeight,
                "PlateNumber": PlateNumber,
                "ProductionDate": ProductionDate,
                "ExpirationDate": ExpirationDate,
                "ProducingArea": ProducingArea,
                "Remark": Remark,
                //"Remark1": Remark1,
                //"Remark2": Remark2,
                //"Remark3": Remark3,
                "Processed": Processed,
            };
            detailList.push(detail);
        });
        var costList = new Array();
        costdom.forEach(function (value, index) {
            var i = value;
            var Id = $("#CostsId" + i).val();
            var EntryId = $("#EntryId" + i).val();
            var CostId = $("#CostType" + i).combobox('getValue');;
            var UnitPrice = $("#UnitPrice" + i).numberbox('getValue');
            var Unit = $("#ChargingUnit" + i).numberbox('getValue');
            var UnitName = $("#ChargingUnit" + i).combobox('getText');
            var number = $("#CNumber" + i).numberbox('getValue');
            var Amount = $("#Amount" + i).numberbox('getValue');

            var cost = {
                "Id": Id,
                "EntryId": EntryId,
                "CostId": CostId,
                "UnitPrice": UnitPrice,
                "Unit": Unit,
                "UnitName": UnitName,
                "Number": number,
                "Amount": Amount,
            };
            costList.push(cost);
        });

        var d = JSON.stringify({ WarehouseEntry: data, Details: detailList, Costs: costList, AttachmentId: $("#hidFileId").val() });


        $.messager.progress({
            title: '请稍后',
            msg: '数据保存中...',
        });
        window.setTimeout(function () {
            $.ajax({
                url: '/GoodsOrder/EditLKWarehouseEntry',
                type: "post",
                data: d,
                contentType: 'application/json; charset=utf-8',
                success: function (json) {
                    $.messager.progress('close');
                    Helper.Show(json.Msg);
                    if (json.Success) {
                        setTimeout(function () { window.location.href = "/GoodsOrder/LKZeroWarehouseEntryList"; }, 2000);
                    }
                }
            });
        }, 2000);
    }

    function confirmLKWarehouseEntry() {
        if (confirm("确认入库后不可更改,确认入库吗?")) {
            editLKWarehouseEntry(true);
        }
    };

    function checkLKWarehouseOut() {
        $.messager.confirm('提示信息', '您确认要复核吗?', function (r) {
            if (!r) { return false; }
            $.post("/GoodsOrder/ReviewLKWarehouseEntry", { id: $("#Id").val() }, function (json) {
                Helper.Show(json.Msg);
                if (json.Success) {
                    setTimeout(function () { window.location.href = "/GoodsOrder/LKZeroWarehouseEntryList"; }, 2000);
                }
            });
        });
    }
</script>
<link href="~/Content/css/custome.css" rel="stylesheet" />
<div title="编辑商品入库单" style="width:auto; height:auto; padding-left:5px; font-size:14px;  ">
    <div class="ftitle">
        @if (Model.WarehouseEntry.Status == (int)Gx.Model.Enums.EntryBillStatus.Submitted)
        {
            <a href="javascript:" class="easyui-linkbutton" iconCls="icon-ok" style="height:32px" onclick="editLKWarehouseEntry(false)">保存</a>
            <a href="javascript:" class="easyui-linkbutton" iconCls="icon-ok" style="height:32px" onclick="confirmLKWarehouseEntry()">确认入库</a>
        }
        @if (!Model.WarehouseEntry.IsReview)
        {
            <a href="javascript:" class="easyui-linkbutton" iconCls="icon-ok" style="height:32px" onclick="checkLKWarehouseOut()">复核</a>
        }
        <a href="javascript:" class="easyui-linkbutton" data-options="iconCls:'icon-print'" onclick="print()">打印</a>
        <a href="/GoodsOrder/LKZeroWarehouseEntryList" class="easyui-linkbutton" iconCls="icon-back" style="height:32px">返回</a>
    </div>
    <form id="fm" method="post" novalidate>
        <input type="hidden" id="Id" value="@Model.WarehouseEntry.Id" />
        <div class="ftitle">基础信息</div>
        <div class="fitem1">
            <label>
                单据编号:
            </label>
            <input class="easyui-textbox" name="BillNo" id="BillNo" value="@Model.WarehouseEntry.BillNo" readonly="readonly" style="width: 173px; height: 30px;">
            <label>
                入库时间:
            </label>
            <input class="easyui-datebox" name="EntryTime" id="EntryTime" value="@Model.WarehouseEntry.EntryTime.ToString("yyyy-MM-dd")" style="width: 173px; height: 30px; " data-options="required:true">
            <label>
                车牌号:
            </label>
            <input name="CarNumber" id="CarNumber" value="@Model.WarehouseEntry.CarNumber" class="easyui-textbox" style="width: 173px; height: 30px;" />
            <label>
                搬运工单号:
            </label>
            <input name="PorterNo" id="PorterNo" value="@Model.WarehouseEntry.PorterNo" class="easyui-textbox" style="width: 173px; height: 30px;" />
        </div>
        <div class="fitem1">
            <label>
                客户:
            </label>
            @*<input type="hidden" id="hidCustomerId" value="@Model.WarehouseEntry.CustomerId" />*@
            <select class="easyui-combogrid" value="@Model.WarehouseEntry.CustomerId" style="width: 173px; height: 30px;" name="CustomerId" id="CustomerId"></select>
            <label>
                客户名称:
            </label>
            <input name="CustomerName" id="CustomerName" value="@Model.WarehouseEntry.CustomerName" class="easyui-textbox" style="width: 173px; height: 30px;" readonly="readonly" />
            <label>
                合同编号:
            </label>
            <input type="hidden" id="ContractId" name="ContractId" />
            <select class="easyui-combogrid" style="width: 173px; height: 30px;" name="ContractNo" id="ContractNo"></select>
            <label>
                租仓类型:
            </label>
            <input type="hidden" id="RentalWarehouseType" name="RentalWarehouseType" value="@Model.WarehouseEntry.RentalWarehouseType" />
            <input name="RentalWarehouseTypeName" id="RentalWarehouseTypeName" value="@Model.WarehouseEntry.RentalWarehouseTypeName" class="easyui-textbox" style="width: 173px; height: 30px;" readonly="readonly" />
        </div>
        <div class="fitem1">
            <label>
                开始日期:
            </label>
            <input class="easyui-datebox" name="BeginTime" id="BeginTime" value="@Model.WarehouseEntry.BeginTime.ToString("yyyy-MM-dd")" style="width: 173px; height: 30px; " data-options="required:true" readonly="readonly">
            <label>
                结束日期:
            </label>
            <input class="easyui-datebox" name="EndTime" id="EndTime" value="@Model.WarehouseEntry.EndTime.ToString("yyyy-MM-dd")" style="width: 173px; height: 30px; " data-options="required:true">
            <label>
                柜号:
            </label>
            <input name="ContainerNumber" id="ContainerNumber" value="@Model.WarehouseEntry.ContainerNumber" class="easyui-textbox" style="width: 173px; height: 30px;" />
            <label>
                按吨操作:
            </label>
            <input class="easyui-switchbutton" id="sbIsByTon" data-options="onText:'是',offText:'否'">
        </div>
        <div class="fitem1">
            <label>
                计费单位:
            </label>
            @*<input type="hidden" name="ChargingUnit" id="ChargingUnit" />*@
            <input name="ChargingUnit" id="ChargingUnit" value="@Model.WarehouseEntry.ChargingUnit" class="easyui-combobox" style="width: 173px; height: 30px;" readonly="readonly" />
            <label>
                冷藏算法:
            </label>
            @*<input type="hidden" name="ColdAlgorithm" id="ColdAlgorithm" />*@
            <input name="ColdAlgorithm" id="ColdAlgorithm" value="@Model.WarehouseEntry.ColdAlgorithm" class="easyui-textbox" style="width: 173px; height: 30px;" readonly="readonly" />
            <label>
                周期:
            </label>
            <input name="Cycle" id="Cycle" value="@Model.WarehouseEntry.Cycle" class="easyui-numberbox" data-options="required: true" style="width: 173px; height: 30px;" autocomplete="off" />
            <label>
                冷藏单价:
            </label>
            <input name="ColdUnitPrice" id="ColdUnitPrice" value="@Model.WarehouseEntry.ColdUnitPrice" class="easyui-numberbox" data-options="required: true,precision:'2'" style="width: 173px; height: 30px;" autocomplete="off" />
        </div>
        <div class="fitem1">
            <label>
                总吨重:
            </label>
            <input name="TotalTon" id="TotalTon" value="@Model.WarehouseEntry.TotalTon" class="easyui-numberbox" data-options="required: true,precision:'4'" style="width: 173px; height: 30px;" autocomplete="off" />
            <label>
                总件数:
            </label>
            <input name="Total" id="Total" value="@Model.WarehouseEntry.Total" class="easyui-numberbox" data-options="required: true" style="width: 173px; height: 30px;" autocomplete="off" />
            <label>
                总金额:
            </label>
            <input name="Amount" id="Amount" value="@Model.WarehouseEntry.Amount" class="easyui-numberbox" data-options="required: true,precision:'2'" style="width: 173px; height: 30px;" autocomplete="off" />
            <label>
                不足n吨算n吨:
            </label>
            <input name="Tonnage" id="Tonnage" value="@Model.WarehouseEntry.Tonnage" class="easyui-numberbox" data-options="required: true" style="width: 173px; height: 30px;" autocomplete="off" />
        </div>
        @*<div class="fitem1">
                <label>
                    柜号:
                </label>
                <input name="ContainerNumber" id="ContainerNumber" value="@Model.WarehouseEntry.ContainerNumber" class="easyui-textbox" style="width: 173px; height: 30px;" />
                <label>
                    按吨操作:
                </label>
                <input class="easyui-switchbutton" id="sbIsByTon" data-options="onText:'是',offText:'否'">
            </div>*@
        <div class="fitem1">
            <label>
                图片:
            </label>
            <input type="hidden" id="hidFileId" />
            <input id="filebox" class="easyui-filebox" name="file" data-options="buttonText:'选择文件',accept:'image/*',onChange:fileChange" /><a href="@Model.FilePath" target="_blank">@Model.FileName</a>
        </div>
        <div class="fitem1">
            <label>
                备注:
            </label>
            <textarea rows="4" cols="4" style="width: 400px; height: 90px; vertical-align: top" name="Remark" id="Remark" autocomplete="off" placeholder="200字以内">@Model.WarehouseEntry.Remark</textarea>
        </div>

        <div id="Wl">
            <div id="tabs" class="easyui-tabs" fit="true" border="false" style="width:500px;height:300px; padding-top:5px;">
                <div title="商品明细">
                    <input id="DomNum" type="hidden" value="@(Model.Details.Count+1)" />
                    @{
                        int i = 1;
                    }
                    <a href="javascript:" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="addDom()">添加</a>
                    <table class="gridtable" id="detailgird">
                        <thead>
                            <tr>
                                <th>商品批号</th>
                                <th>商品</th>
                                <th>规格</th>
                                <th>仓位</th>
                                <th>件重</th>
                                <th>件数</th>
                                <th>面积</th>
                                <th>每板件数</th>
                                <th>总吨重</th>
                                <th>板数</th>
                                <th>生产日期</th>
                                <th>保质日期</th>
                                <th>产地</th>
                                <th>备注</th>
                                <th>已处理</th>
                                <th>操作</th>
                            </tr>
                            @foreach (var item in Model.Details)
                            {
                                <tr id="@i">
                                    <td>
                                        <input class="easyui-textbox" id="@("GoodsNo")@i" name="@("GoodsNo")@i" value="@item.GoodsNo" style="width: 80px; height: 30px;" readonly="readonly">
                                        <input type="hidden" id="@("DetailDomId")@i" value="@i" />
                                        <input type="hidden" id="@("DetailId")@i" value="@item.Id" />
                                        <input type="hidden" id="@("EntryId")@i" value="@item.EntryId" />
                                    </td>
                                    <td><select class="easyui-combobox" id="@("GoodsId")@i" style="width: 120px; height: 30px;" data-options="editable: false,prompt:'商品id;'"></select></td>
                                    <td><select class="easyui-combobox" id="@("GoodsSpecId")@i" style="width: 80px; height: 30px;" data-options="editable: false,prompt:'规格;'"></select></td>
                                    <td><select class="easyui-combobox" id="@("WareHouseId")@i" style="width: 120px; height: 30px;" data-options="editable: false,prompt:'仓位;'"></select></td>
                                    <td><input id="@("Weight")@i" name="@("Weight")@i" value="@item.Weight" class="easyui-numberbox" data-options="precision:'4',prompt:'件重',onChange:calculateWeight" style="width: 80px; height: 30px;" /></td>
                                    <td><input id="@("Number")@i" class="easyui-numberbox" value="@item.Number" data-options="prompt:'件数',onChange:calculateWeight" style="width: 80px; height: 30px;" /></td>
                                    <td><input id="@("Area")@i" name="@("Area")@i" value="@item.Area" class="easyui-numberbox" data-options="precision:'2',prompt:'面积'" style="width: 80px; height: 30px;" /></td>
                                    <td><input id="@("AvNumber")@i" name="@("AvNumber")@i" value="@item.AvNumber" class="easyui-numberbox" data-options="precision:'2',prompt:'每板件数'" style="width: 80px; height: 30px;" /></td>
                                    <td><input id="@("TonWeight")@i" name="@("TonWeight")@i" value="@item.TonWeight" class="easyui-numberbox" data-options="precision:'4',prompt:'吨重'" style="width: 80px; height: 30px;" /></td>
                                    <td><input id="@("PlateNumber")@i" class="easyui-numberbox" value="@item.PlateNumber" data-options="prompt:'板数'" style="width: 80px; height: 30px;" /></td>
                                    <td><input id="@("ProductionDate")@i" name="@("ProductionDate")@i" value="@item.ProductionDate.ToString("yyyy-MM-dd")" class="easyui-datebox" style="width: 120px; height: 30px;" /></td>
                                    <td><input id="@("ExpirationDate")@i" name="@("ExpirationDate")@i" value="@item.ExpirationDate.ToString("yyyy-MM-dd")" class="easyui-datebox" style="width: 120px; height: 30px;" /></td>
                                    <td><input class="easyui-textbox" id="@("ProducingArea")@i" name="@("ProducingArea")@i" value="@item.ProducingArea" style="width: 80px; height: 30px;"></td>
                                    <td><input class="easyui-textbox" id="@("Remark")@i" name="@("Remark")@i" value="@item.Remark" style="width: 80px; height: 30px;"></td>
                                    <td><input class="easyui-switchbutton" id="sb@("Processed")@i" value="@item.Processed" data-options="onText:'是',offText:'否'"></td>
                                    <td><a href="javascript:" class="easyui-linkbutton" iconcls="icon-no" plain="true" style=" width:80px;" onclick="delDom(@i)">删除</a></td>
                                </tr>
                                i++;
                            }
                        </thead>
                    </table>
                    @{
                        i = 1;
                    }
                    @foreach (var item in Model.Details)
                    {
                        <script type="text/javascript">
$(function () {
                InitWareHouse(@i);
            InitGoods(@i);
    InitGoodsSpecCombobox(@i);
    $('@("#GoodsId")@i').combogrid('setValue', '@item.GoodsId');
    $('@("#GoodsSpecId")@i').combobox('setValue', '@item.GoodsSpecId');
    $('@("#WareHouseId")@i').combotree('setValue', '@item.WareHouseId');
                            $('@("#sbProcessed")@i').switchbutton({ checked: @Html.Raw(item.Processed ? "true" : "false") });
});
                        </script>
                        i++;
                    }
                </div>
                <div title="其他费用">
                    <input id="CostDomNum" type="hidden" value="@(Model.Costs.Count+1)" />
                    @{
                        int ci = 1;
                    }
                    <a href="javascript:" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="addDom2()">添加</a>
                    <table class="gridtable" id="costgird">
                        <thead>
                            <tr>
                                <th>费用类型</th>
                                <th>杂费单价</th>
                                <th>单位</th>
                                <th>计算数量</th>
                                <th>金额</th>
                                <th>操作</th>
                            </tr>
                            @foreach (var item in Model.Costs)
                            {
                                <tr id="@("CostTr")@ci">
                                    <td>
                                        <input id="@("CostType")@ci" class="easyui-combobox" value="@item.CostId" data-options="prompt:'费用类型',onChange:calculateAmount" style="width: 173px; height: 30px;" />
                                        <input type="hidden" id="@("CostTypeId")@ci" value="@item.CostId" />
                                        <input type="hidden" id="@("CostDomId")@ci" value="@ci" />
                                        <input type="hidden" id="@("CostsId")@ci" value="@item.Id" />
                                        <input type="hidden" id="@("EntryId")@ci" value="@item.EntryId" />
                                    </td>
                                    <td><input id="@("UnitPrice")@ci" name="@("UnitPrice")@ci" value="@item.UnitPrice" class="easyui-numberbox" data-options="precision:'2',prompt:'杂费单价',onChange:calculateAmount" style="width: 80px; height: 30px;" /></td>
                                    <td><input id="@("ChargingUnit")@ci" class="easyui-combobox" value="@item.Unit" data-options="prompt:'单位'" style="width: 173px; height: 30px;" /></td>
                                    <td><input id="@("CNumber")@ci" class="easyui-numberbox" value="@item.Number" data-options="prompt:'计算数量',onChange:calculateAmount" style="width: 173px; height: 30px;" /></td>
                                    <td><input id="@("Amount")@ci" name="@("Amount")@ci" value="@item.Amount" class="easyui-numberbox" data-options="precision:'2',prompt:'金额'" style="width: 173px; height: 30px;" /></td>
                                    <td><a href="javascript:" class="easyui-linkbutton" iconcls="icon-no" plain="true" style=" width:80px;" onclick="delDom2(@ci)">删除</a></td>
                                </tr>
                                ci++;
                            }
                        </thead>
                    </table>
                    @{
                        ci = 1;
                    }
                    @foreach (var item in Model.Costs)
                    {
                        <script type="text/javascript">
$(function () {
    InitCostTypesCombogrid2(@ci);
    InitChargingUnitCombobox(@ci);
});
                        </script>
                        ci++;
                    }
                </div>
            </div>
        </div>
        <div class="fitem1">
            @{
                var modifyuser = Model.WarehouseEntry.ModifyUserId == 0 ? Gx.Dal.Shared.UserContext.CurrentUser.EmpName : Model.WarehouseEntry.ModifyUser;
                var modifytime = Model.WarehouseEntry.ModifyTime.ToString("yyyy-MM-dd") == "1911-01-01" ? "" : Model.WarehouseEntry.ModifyTime.ToString("yyyy-MM-dd");
            }
            <label>
                制单人:
            </label>
            <label>
                @Model.WarehouseEntry.CreateUser
            </label>

            <label>
                制单日期:
            </label>
            <label>
                @Model.WarehouseEntry.CreateTime.ToString("yyyy-MM-dd")
            </label>
            <label>
                修改人:
            </label>
            <label>
                @modifyuser
            </label>
            <label>
                修改日期:
            </label>
            <label>
                @modifytime
            </label>
        </div>
    </form>
    <div id="customerselecttoolbar2">
        <input id="SelectCustomerText2" class="easyui-textbox " style="width: 173px; height: 30px;" />
        <a href="javascript:" class="easyui-linkbutton" plain="true" iconcls="icon-search" onclick="querycustomer2()">查询</a>
    </div>
</div>











